package com.pig4cloud.pigx.wallet.dto;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.pig4cloud.pigx.common.customize.utils.serializer.BigDecimalToPlainStringSerializer;
import com.pig4cloud.pigx.wallet.constant.WalletStatusEnum;
import com.pig4cloud.pigx.wallet.entity.RechargeRecord;
import com.pig4cloud.pigx.wallet.entity.WithdrawalRecord;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * @Description: 充值提现消息通知
 * @Date: 2022/10/24 10:56
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ChargeMentionNotificationDTO {

    /**
     * 充提记录主键ID
     */
    @ApiModelProperty(value = "充提记录主键ID")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    /**
     * 用户id
     */
    @ApiModelProperty(value = "用户id")
    private Long userId;

    /**
     * 数量
     */
    @ApiModelProperty(value = "数量")
    @JsonSerialize(using = BigDecimalToPlainStringSerializer.class)
    private BigDecimal quantity;

    /**
     * 币种（0：USDT）
     */
    @ApiModelProperty(value = "币种（1：USDT）")
    private String currency;

    /**
     * 类型（充值状态字典项：user_fund_recharge_type， 提现状态字典项：无（提现））
     */
    @ApiModelProperty(value = "类型（充值状态字典项：user_fund_recharge_type， 提现状态字典项：无（提现））")
    private String type;

    /**
     * 状态（充值状态字典项：recharge_state， 提现状态字典项：withdrawal_state）
     */
    @ApiModelProperty(value = "状态（充值状态字典项：recharge_state， 提现状态字典项：withdrawal_state）")
    private String state;

    /**
     * 通知类型（字典项：wallet_notice，1：充值，2：提现。。。）
     */
    @ApiModelProperty(value = "通知类型（字典项：wallet_notice，1：充值，2：提现。。。）")
    private String noticeType;

    /**
     * 语言
     */
    @ApiModelProperty(value = "语言")
    private String language;

    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间")
    private LocalDateTime createTime;

    public ChargeMentionNotificationDTO(RechargeRecord rechargeRecord) {
        this.id = rechargeRecord.getId();
        this.userId = rechargeRecord.getUserId();
        this.quantity = rechargeRecord.getQuantity();
        this.currency = rechargeRecord.getCurrency();
        this.type = rechargeRecord.getType();
        this.state = rechargeRecord.getState();
        this.noticeType = WalletStatusEnum.WalletNotice.RECHARGE.getCode();
        this.createTime = LocalDateTime.now();
    }

    public ChargeMentionNotificationDTO(WithdrawalRecord withdrawalRecord) {
        this.id = withdrawalRecord.getId();
        this.userId = withdrawalRecord.getUserId();
        this.quantity = withdrawalRecord.getQuantity();
        this.currency = withdrawalRecord.getCurrency();
        this.type = WalletStatusEnum.WalletNotice.WITHDRAWAL.getCode();
        this.state = withdrawalRecord.getState();
        this.noticeType = WalletStatusEnum.WalletNotice.WITHDRAWAL.getCode();
        this.createTime = LocalDateTime.now();
    }
}

